package org.finesys.chat.core.base.embedding.store.pgvector.factory;

import org.finesys.chat.core.base.embedding.store.pgvector.MetadataHandler;
import org.finesys.chat.core.base.embedding.store.pgvector.MetadataStorageConfig;
import org.finesys.chat.core.base.embedding.store.pgvector.handler.JSONBMetadataHandler;
import org.finesys.chat.core.base.embedding.store.pgvector.handler.JSONMetadataHandler;

import static org.finesys.chat.core.base.embedding.store.pgvector.constants.MetadataStorageMode.*;

public class MetadataHandlerFactory {

    public static MetadataHandler get(MetadataStorageConfig config) {
        if (config.storageMode().equals(COMBINED_JSON)) {
            return new JSONMetadataHandler(config);
        } else if (config.storageMode().equals(COMBINED_JSONB)) {
            return new JSONBMetadataHandler(config);
        } else if (config.storageMode().equals(COLUMN_PER_KEY)) {
            return new JSONBMetadataHandler(config);
        } else {
             throw new RuntimeException(String.format("Type %s not handled.", config.storageMode()));
        }
    }
}
